import { Prisma } from '@prisma/client';
import { Transform } from 'class-transformer';
import { IsDefined, IsNotEmptyObject } from 'class-validator';
import { BaseDto, BaseFindDto, BaseQueryDto } from './base.dto';

export class CategoryCreateDto extends BaseDto<Prisma.CategoryCreateInput> {}

export class CategoryUpdateDto extends BaseDto<Prisma.CategoryUpdateInput> {
  @IsDefined({ message: '条件必填' })
  @IsNotEmptyObject({ nullable: false }, { message: '条件参数必填' })
  where: Prisma.CategoryWhereUniqueInput;
}

export class CategoryRemoveDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;
}

export class CategoryFindDto extends BaseFindDto<
  Prisma.CategoryWhereUniqueInput,
  Prisma.CategorySelect
> {}

export class CategoryQueryDto extends BaseQueryDto<Prisma.CategoryWhereUniqueInput> {}

export class CategoryListDto extends BaseQueryDto<Prisma.CategoryWhereUniqueInput> {}
